import { Component, OnInit, ViewChild, Inject, Injectable, Injector} from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { STColumn, STComponent, STColumnButton, STPage } from '@delon/abc';
import { SFSchema, SFComponent } from '@delon/form';
import { GridComponent, HttpService, SupDic} from 'lbf';
import { NzMessageService} from 'ng-zorro-antd';
import { Router } from '@angular/router';

@Component({
  selector: 'app-ysgzz-ysgzzxx',
  templateUrl: './ysgzzxx.component.html',
  styleUrls: ['./ysgzzxx.component.less']
})
export class YsgzzYsgzzxxComponent implements OnInit {

  yxypData = []
  yxzlData = []

  lj = 'bclj';
  yz: any;
  sfby: any;

  xxgwxys: any;
  czbqgsh: any;
  sfczlcjb: any;
  ypData: any;
  zlData = [];
  lsljData: any;
  lsyzData: any;
  jkcfData: any;
  editData = {
    mzh: '123',
    sc: '入径病种：高血压，入径医院：山海乡卫生院',
    sfz: '2015329620018',
    xm: '小明',
    xb: '女',
    ks: '22',
    ys: '小红',
    rjbz: '高血压',
    sg: '170',
    tz: '70',
    xy: '140',
    xt: '140',
    sjh: '17723244323',
    dz: '浙江省'
  }
  page: STPage = {
    show: false
  }

  editSchema :SFSchema = {
    properties: {
      mzh: {
        type: 'string',
        title: '门诊号',
        ui: {
          grid: {
            span: 4
          }
        }
      },
      sc: {
        type: 'string',
        title: '首次',
        ui: {
          grid: {
            span: 20
          }
        }
      },
      sfz: {
        type: 'string',
        title: '身份证',
        ui: {
          grid: {
            span: 4
          }
        }
      },
      xm: {
        type: 'string',
        title: '姓名',
        ui: {
          grid: {
            span: 5
          }
        }
      },
      xb: {
        type: 'string',
        title: '性别',
        ui: {
          grid: {
            span: 5
          }
        }
      },
      ks: {
        type: 'string',
        title: '科室',
        ui: {
          grid: {
            span: 5
          }
        }
      },
      ys: {
        type: 'string',
        title: '医生',
        ui: {
          grid: {
            span: 5
          }
        }
      },
      rjbz: {
        type: 'string',
        title: '入境病种',
        ui: {
          grid: {
            span: 4
          }
        }
      },
      sg: {
        type: 'string',
        title: '身高',
        ui: {
          grid: {
            span: 5
          }
        }
      },
      tz:{
        type: 'string',
        title: '体重',
        ui: {
          grid: {
            span: 5
          }
        }
      },
      xy: {
        type: 'string',
        title: '血压',
        ui: {
          grid: {
            span: 5
          }
        }
      },
      xt: {
        type: 'string',
        title: '血糖',
        ui: {
          grid: {
            span: 5
          }
        }
      },
      sjh: {
        type: 'string',
        title: '手机号码',
        ui: {
          grid: {
            span: 4
          }
        }
      },
      dz:{
        type: 'string',
        title: '地址',
        ui: {
          grid: {
            span: 20
          }
        }
      }
    },
    ui: {
      spanLabelFixed: 80,
      grid: {
        span: 4
      }
    }
  }
  
  
  serSchema: SFSchema = {
    properties: {
      sfz: {
        title: '身份证',
        type: 'string'
      },
      xm: {
        type: 'string',
        title: '姓名'
      },
      xb: {
        type: 'string',
        title: '性别'
      }
    }
  }

  ypColumns: STColumn[] = [
     {title: '选择',type: 'checkbox'},
      {title: '药品编码',index: 'ypbm',width: 250},
      {title: '药品名称',index: 'ypmc1',width: 400},
      {title: '自付比例',index: 'zfbl'},
      {title: '转换比',index: 'zhb'},
      {title: '厂家',index: 'cj'}
  ]

  zlColumns: STColumn[] = [
    {title: '选择',type: 'checkbox'},
     {title: '诊疗编码',index: 'zlbm',width: 250},
     {title: '诊疗名称',index: 'zlmc'},
 ]

 lsljColumns:STColumn[] = [
   {title: '就诊日期',index:''},
   {title: '就诊医院',index:''},
   {title: '路径病种',index:''},
   {title: '路径',index:''},
   {title: '医生',index:''},
   {title: '医压',index:''},
   {title: '血糖',index:''},
 ]

 lsyzColumns: STColumn[] = [
   {title: '医嘱日期',index:''},
   {title: '药品名称',index: ''},
   {title: '数量',index: ''},
   {title: '频次',index: ''},
   {title: '天数',index: ''},
   {title: '用量',index: ''}
 ]
 
 jkcfColumns: STColumn[] = [
  {title: '医嘱日期',index:''},
  {title: '诊疗名称',index: ''},
  {title: '数量',index: ''}
]

@ViewChild('sf',{static: false}) sf: SFComponent;

  constructor(private lbservice: HttpService,
    private msgSrv: NzMessageService ,
    private route: Router,
    private supdic: SupDic) { }

  ngOnInit() { 
    console.log(123)
    this.lbservice.lbservice('mblclj_ypcx',{para: this.editData}).then(res =>{
       this.ypData = res.message.list.slice(0,5)
       this.zlData = res.message.list[5].zl;
    })

    // this.lbservice.lbservice('mblclj_zlcx',{para: this.editData}).then(res =>{
    //   this.ypData = res.message.list;
    // })
    }

  ypChange(data){
    if(data.checkbox !== undefined){
      this.yxypData.push(data.checkbox);
    }
    
  }

  zlChange(data){
    if(data.checkbox !== undefined){
      this.yxzlData.push(data.checkbox);
    }
  }

  show(){
   
    console.log(this.yxypData[this.yxypData.length-1])
    console.log(this.yxzlData[this.yxzlData.length-1])
  }

  next(){
    this.route.navigateByUrl('/ysgzz/kjjkcf');
  }

  return(){
    this.lj = 'bclj';
  }

  close(){
    this.lj = 'bclj';
  }

  cancel(){
    this.lj = 'bclj';
  }

  query(){

  }

  log(event){

  }
}
